

#include "EnergyConvectionADKernelSUPG.h"

registerMooseObject("TrilobitaApp", EnergyConvectionADKernelSUPG);

InputParameters
EnergyConvectionADKernelSUPG::validParams()
{
    InputParameters params = ADKernelGrad::validParams();
    params.addClassDescription(
        "SUPG stablization term for the advection portion of the pyrolysis energy equation.");
    params.addRequiredCoupledVar("velocity", "Velocity vector variable.");
    return params;
}

EnergyConvectionADKernelSUPG::EnergyConvectionADKernelSUPG(const InputParameters& parameters)
    : ADKernelGrad(parameters), 
    _velocity(adCoupledVectorValue("velocity")),
    _energy_convection_strong_residual_factor(getADMaterialProperty<RealVectorValue>("energy_convection_strong_residual_factor"))
{
}

ADRealVectorValue
EnergyConvectionADKernelSUPG::precomputeQpResidual()
{
    ADReal tau =
        _current_elem->hmin() /
        (2 * (_velocity[_qp] + RealVectorValue(libMesh::TOLERANCE * libMesh::TOLERANCE)).norm());
    return (tau * _velocity[_qp]) * (_energy_convection_strong_residual_factor[_qp] * _grad_u[_qp]);
}
